package com.just521.xinshoutong;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;

import com.feedback.UMFeedbackService;
import com.just521.xinshoutong.calendar.Activity_Calendar;
import com.just521.xinshoutong.database.NoteDBCtrl.DBAccessListener;
import com.just521.xinshoutong.database.NoteDBCtrl.DBRequestParam;

public class Activity_note_edit_text extends ActivityBase implements OnClickListener,
DBAccessListener{

	byte[] mlock=new byte[0];
	String mSourceText; 
	int mSourceID=-1;
	EditText metText;
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.note_edit_text);
		Intent it=getIntent();
		if(it!=null){
			
			mSourceText=it.getStringExtra("sourcetext");
			mSourceID=it.getIntExtra("sourceid",-1);
		}
		metText=(EditText)findViewById(R.id.note_edit_text);
		if(mSourceText!=null){
			metText.setText(mSourceText);
		}
		Button btn=(Button)findViewById(R.id.note_edit_text_confirm);
		btn.setOnClickListener(this);
		btn=(Button)findViewById(R.id.note_edit_text_cancel);
		btn.setOnClickListener(this);
	}
	
	
	protected void onDestroy() {
		super.onDestroy();
		
	}
	protected void onResume() {
		super.onResume();
		
	}
	@Override
	public void onClick(View v) {
		switch(v.getId()){
//		case R.id.main_setting:
//			do_main_setting();
//			break;
		case R.id.note_edit_text_confirm:
			String text=metText.getText().toString();
			Intent intent = new Intent();
    		intent.putExtra("notetext", text);
    		intent.putExtra("isnew", mSourceText==null?true:false);
    		intent.putExtra("sourceid", mSourceID);
			setResult(RESULT_OK, intent); 
			((InputMethodManager)getSystemService(Activity.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(metText.getWindowToken(), InputMethodManager.HIDE_IMPLICIT_ONLY);
			finish();
			break;
		case R.id.note_edit_text_cancel:
			((InputMethodManager)getSystemService(Activity.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(metText.getWindowToken(), InputMethodManager.HIDE_IMPLICIT_ONLY);
			finish();
			break;	
		case R.id.main_viewmode:
//			mtoastlist.showanimation();
			startActivity(new Intent(this,Activity_Calendar.class));
			break;	
		default:
			break;
		}	
	}
	
	void do_main_setting(){
	
	}

	void do_main_region(){
	
	}

	void do_main_nearby(){
	
	}

	void do_main_feedback(){
		UMFeedbackService.openUmengFeedbackSDK(this);
	}
	
	
	public void onDBSuccess(DBRequestParam param){
		
		
	}
	public void onDBError(DBRequestParam param){
		
	}
	
	
	
	
	
	
	
	

}

